package com.huawei.service.impl;

import com.huawei.dao.SkuMapper;
import com.huawei.dao.SpuMapper;
import com.huawei.entity.Shangpinsku;
import com.huawei.entity.Shangpinspu;
import com.huawei.service.SpuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @ClassName SpuImpl
 * @Description TODO
 * @Author 快乐的大胖
 * @Date 2021/11/30 16:29
 */
@Service
public class SpuImpl  implements SpuService {

    @Resource
    SpuMapper spuMappers;
    @Resource
    SkuMapper skuMappers;
    @Override
    public List<Shangpinspu> selectAll(Map<String, Object> pars) {

        List<Shangpinspu> list= spuMappers.selectAll(pars);

        for(Shangpinspu n:list){
           n.setSkuList(skuMappers.getId(n.getSku_id()));
    }
          return list;
    }


    @Override
     public int insert(Shangpinspu shangpinspu) {

        return spuMappers.insert(shangpinspu);
     }

    @Override
    public int selectCount(Map<String, Object> map) {
        return spuMappers.selectCount(map);
    }

    @Override
    public int update(Shangpinspu shangpinspu) {

        return  spuMappers.update(shangpinspu);
    }

    @Override
    public int update1(int spu_id, String status) {
        return spuMappers.update1(spu_id,status);
    }

    @Override
    public int delete(int spu_id) {

        return spuMappers.delete(spu_id);
    }

    @Override
    public Shangpinspu getId(int spu_id) {
        return spuMappers.getId(spu_id);
    }
}
